﻿using UnityEngine;
using System.Collections;

public enum ELevelButton
{
    LEVEL,
    PAGE,
    NEXT,
    BACK,
    PLAY,
}

public class UILevelButton : MonoBehaviour {
    public ELevelButton eLevelButton;

    void OnClick()
    {
        LevelManager lv = LevelManager.Instance;
       
        switch (eLevelButton)
        {
            case ELevelButton.LEVEL:

                lv.iCurrentLevel = int.Parse(this.GetComponentInChildren<UILabel>().text);
                lv.ToUI();
                break;
            case ELevelButton.PAGE:

                lv.iCurrentLevel += 3;
                if (lv.iCurrentLevel > lv.LevelDatabase.Waves.Length)
                    lv.iCurrentLevel = lv.LevelDatabase.Waves.Length;
                lv.ToUI();
                break;
            case ELevelButton.NEXT:
                if (lv.iCurrentLevel < lv.LevelDatabase.Waves.Length )
                {
                    lv.iCurrentLevel++;
                    lv.ToUI();
                }
                
                break;
            case ELevelButton.BACK:
                if (lv.iCurrentLevel > 1)
                {
                    lv.iCurrentLevel--;
                    lv.ToUI();
                }
                break;
            case ELevelButton.PLAY:
                GameManager.levelManager = lv;
                Application.LoadLevel("Game");
                break;

        }
        
    }
}
